package org.apache.flink.runtime.resourcemanager;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;

import org.apache.flink.runtime.resourceprovider.ResourceProvider;
import org.apache.flink.runtime.rest.messages.taskmanager.SlotInfo;
import org.apache.flink.runtime.rest.messages.taskmanager.ResourceProviderInfo;
import org.apache.flink.util.Preconditions;

/** Contains the base information about a {@link ResourceProvider} and its allocated slots. */
public class ResourceProviderInfoWithSlots implements Serializable {

    private static final long serialVersionUID = 1L;

    private final ResourceProviderInfo resourceProviderInfo;
    private final Collection<SlotInfo> allocatedSlots;

    public ResourceProviderInfoWithSlots(
            ResourceProviderInfo resourceProviderInfo, Collection<SlotInfo> allocatedSlots) {
        this.resourceProviderInfo = Preconditions.checkNotNull(resourceProviderInfo);
        this.allocatedSlots = Preconditions.checkNotNull(allocatedSlots);
    }

    public final Collection<SlotInfo> getAllocatedSlots() {
        return Collections.unmodifiableCollection(allocatedSlots);
    }

    public ResourceProviderInfo getTaskManagerInfo() {
        return resourceProviderInfo;
    }
}
